Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #95658

Closed
wants to merge 26 commits into from
Closed

Conversation

Dylan-DPC
Copy link
Member

Successful merges:

Failed merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

compiler-errors and others added 26 commits April 2, 2022 15:29
When encountering an unsatisfied trait bound, if there are no other
suggestions, mention all the types that *do* implement that trait:

```
error[E0277]: the trait bound `f32: Foo` is not satisfied
  --> $DIR/impl_wf.rs:22:6
   |
LL | impl Baz<f32> for f32 { }
   |      ^^^^^^^^ the trait `Foo` is not implemented for `f32`
   |
   = help: the following other types implement trait `Foo`:
             Option<T>
             i32
             str
note: required by a bound in `Baz`
  --> $DIR/impl_wf.rs:18:31
   |
LL | trait Baz<U: ?Sized> where U: Foo { }
   |                               ^^^ required by this bound in `Baz`
```

Mention implementers of traits in `ImplObligation`s.

Do not mention other `impl`s for closures, ranges and `?`.
…ied-trait, r=davidtwco

Mention implementers of unsatisfied trait

When encountering an unsatisfied trait bound, if there are no other
suggestions, mention all the types that *do* implement that trait:

```
error[E0277]: the trait bound `f32: Foo` is not satisfied
  --> $DIR/impl_wf.rs:22:6
   |
LL | impl Baz<f32> for f32 { }
   |      ^^^^^^^^ the trait `Foo` is not implemented for `f32`
   |
   = help: the trait `Foo` is implemented for `i32`
note: required by a bound in `Baz`
  --> $DIR/impl_wf.rs:18:31
   |
LL | trait Baz<U: ?Sized> where U: Foo { }
   |                               ^^^ required by this bound in `Baz`
```
```
error[E0277]: the trait bound `u32: Foo` is not satisfied
  --> $DIR/associated-types-path-2.rs:29:5
   |
LL |     f1(2u32, 4u32);
   |     ^^ the trait `Foo` is not implemented for `u32`
   |
   = help: the trait `Foo` is implemented for `i32`
note: required by a bound in `f1`
  --> $DIR/associated-types-path-2.rs:13:14
   |
LL | pub fn f1<T: Foo>(a: T, x: T::A) {}
   |              ^^^ required by this bound in `f1`
```

Suggest dereferencing in more cases.

Fix rust-lang#87437, fix rust-lang#90970.
explicitly distinguish pointer::addr and pointer::expose_addr

`@bgeron` pointed out that the current docs promise that `ptr.addr()` and `ptr as usize` are equivalent. I don't think that is a promise we want to make. (Conceptually, `ptr as usize` might 'escape' the provenance to enable future `usize as ptr` casts, but `ptr.addr()` dertainly does not do that.)

So I propose we word the docs a bit more carefully here. `@Gankra` what do you think?
Fix late-bound ICE in `dyn` return type suggestion

This fixes the root-cause of the attached issues -- the root problem is that we're using the return type from a signature with late-bound instead of early-bound regions. The change on line 1087 (`let Some(liberated_sig) = typeck_results.liberated_fn_sigs().get(fn_hir_id) else { return false; };`) makes sure we're grabbing the _right_ return type for this suggestion to check the `dyn` predicates with.

Fixes rust-lang#91801
Fixes rust-lang#91803

This fix also includes some drive-by changes, specifically:

1. Don't suggest boxing when we have `-> dyn Trait` and are already returning `Box<T>` where `T: Trait` (before we always boxed the value).
2. Suggestion applies even when the return type is a type alias (e.g. `type Foo = dyn Trait`). This does cause the suggestion to expand to the aliased type, but I think it's still beneficial.
3. Split up the multipart suggestion because there's a 6-line max in the printed output...

I am open to splitting out the above changes, if we just want to fix the ICE first.

cc: ``@terrarier2111`` and rust-lang#92289
…n1011

Note invariance reason for FnDef types

Fixes rust-lang#95272. Is it worthwhile even printing a variance explanation here? Or should I try to track down which function parameter is responsible for the invariance?

r? `@Aaron1011` since you wrote rust-lang#89336
interpret: remove MemoryExtra in favor of giving access to the Machine

The Miri PR for this is upcoming.

r? `@oli-obk`
…Jung

Update `NonNull` pointer provenance methods' documentation

 - Add links to equivalent methods on raw pointers
…locks, r=davidtwco

Refactor: remove unnecessary nested blocks
`CandidateSource::XCandidate` -> `CandidateSource::X`
@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Apr 4, 2022
@Dylan-DPC
Copy link
Member Author

@bors r+ rollup=never p=5

@bors
Copy link
Contributor

bors commented Apr 4, 2022

📌 Commit 7b7a622 has been approved by Dylan-DPC

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Apr 4, 2022
@bors
Copy link
Contributor

bors commented Apr 4, 2022

⌛ Testing commit 7b7a622 with merge 8c4e5d02f5d227326c3905d4f15561341741bde6...

@bors
Copy link
Contributor

bors commented Apr 4, 2022

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 4, 2022
@Dylan-DPC Dylan-DPC closed this Apr 4, 2022
@Dylan-DPC Dylan-DPC deleted the rollup-d9zj7q8 branch April 4, 2022 23:52
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-nopt failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

---- [ui (nll)] ui/associated-types/cache/project-fn-ret-invariant.rs#krisskross stdout ----
diff of stderr:

10    |     ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
11    |
12    = help: consider adding the following bound: `'a: 'b`
-    = note: requirement occurs because of the type Type<'_>, which makes the generic argument '_ invariant
-    = note: the struct Type<'a> is invariant over the parameter 'a
+    = note: requirement occurs because of the type `Type<'_>`, which makes the generic argument `'_` invariant
+    = note: the struct `Type<'a>` is invariant over the parameter `'a`
15    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
17 error: lifetime may not live long enough


26    |     ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
27    |
28    = help: consider adding the following bound: `'b: 'a`
-    = note: requirement occurs because of the type Type<'_>, which makes the generic argument '_ invariant
-    = note: the struct Type<'a> is invariant over the parameter 'a
+    = note: requirement occurs because of the type `Type<'_>`, which makes the generic argument `'_` invariant
+    = note: the struct `Type<'a>` is invariant over the parameter `'a`
31    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
32 
33 help: `'a` and `'b` must be the same: replace one with the other

The actual stderr differed from the expected stderr.
The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.nll/project-fn-ret-invariant.krisskross.nll.stderr
To only update this specific test, also pass `--test-args associated-types/cache/project-fn-ret-invariant.rs`


error in revision `krisskross`: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/associated-types/cache/project-fn-ret-invariant.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--cfg" "krisskross" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.nll" "-Zborrowck=mir" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.nll/auxiliary"
stdout: none
--- stderr -------------------------------
error: lifetime may not live long enough
   |
   |
LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
   |              --  -- lifetime `'b` defined here
   |              |
   |              lifetime `'a` defined here
...
LL |     (a, b) //[krisskross]~ ERROR E0623
   |     ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
   |
   = help: consider adding the following bound: `'a: 'b`
   = note: requirement occurs because of the type `Type<'_>`, which makes the generic argument `'_` invariant
   = note: the struct `Type<'a>` is invariant over the parameter `'a`
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
  --> /checkout/src/test/ui/associated-types/cache/project-fn-ret-invariant.rs:56:5
   |
   |
LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
   |              --  -- lifetime `'b` defined here
   |              |
   |              lifetime `'a` defined here
...
LL |     (a, b) //[krisskross]~ ERROR E0623
   |     ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
   |
   = help: consider adding the following bound: `'b: 'a`
   = note: requirement occurs because of the type `Type<'_>`, which makes the generic argument `'_` invariant
   = note: the struct `Type<'a>` is invariant over the parameter `'a`
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance

help: `'a` and `'b` must be the same: replace one with the other
error: aborting due to 2 previous errors
------------------------------------------



---- [ui (nll)] ui/associated-types/cache/project-fn-ret-invariant.rs#transmute stdout ----
diff of stderr:

7 LL |     bar(foo, x)
8    |     ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
9    |
-    = note: requirement occurs because of the type Type<'_>, which makes the generic argument '_ invariant
-    = note: the struct Type<'a> is invariant over the parameter 'a
+    = note: requirement occurs because of the type `Type<'_>`, which makes the generic argument `'_` invariant
+    = note: the struct `Type<'a>` is invariant over the parameter `'a`
12    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
14 error: aborting due to previous error


The actual stderr differed from the expected stderr.
The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.nll/project-fn-ret-invariant.transmute.nll.stderr
To only update this specific test, also pass `--test-args associated-types/cache/project-fn-ret-invariant.rs`


error in revision `transmute`: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/associated-types/cache/project-fn-ret-invariant.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--cfg" "transmute" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.nll" "-Zborrowck=mir" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.nll/auxiliary"
stdout: none
--- stderr -------------------------------
error: lifetime may not live long enough
   |
   |
LL | fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> {
   |        -- lifetime `'a` defined here
...
LL |     bar(foo, x) //[transmute]~ ERROR E0759
   |     ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
   |
   = note: requirement occurs because of the type `Type<'_>`, which makes the generic argument `'_` invariant
   = note: the struct `Type<'a>` is invariant over the parameter `'a`
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: aborting due to previous error
------------------------------------------



---- [ui (nll)] ui/associated-types/cache/project-fn-ret-invariant.rs#oneuse stdout ----
diff of stderr:

10    |             ^^^^^^^^^ argument requires that `'a` must outlive `'b`
11    |
12    = help: consider adding the following bound: `'a: 'b`
-    = note: requirement occurs because of the type Type<'_>, which makes the generic argument '_ invariant
-    = note: the struct Type<'a> is invariant over the parameter 'a
+    = note: requirement occurs because of the type `Type<'_>`, which makes the generic argument `'_` invariant
+    = note: the struct `Type<'a>` is invariant over the parameter `'a`
15    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
17 error: lifetime may not live long enough


26    |             ^^^^^^^^^ argument requires that `'b` must outlive `'a`
27    |
28    = help: consider adding the following bound: `'b: 'a`
-    = note: requirement occurs because of the type Type<'_>, which makes the generic argument '_ invariant
-    = note: the struct Type<'a> is invariant over the parameter 'a
+    = note: requirement occurs because of the type `Type<'_>`, which makes the generic argument `'_` invariant
+    = note: the struct `Type<'a>` is invariant over the parameter `'a`
31    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
32 
33 help: `'a` and `'b` must be the same: replace one with the other

The actual stderr differed from the expected stderr.
The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.nll/project-fn-ret-invariant.oneuse.nll.stderr
To only update this specific test, also pass `--test-args associated-types/cache/project-fn-ret-invariant.rs`


error in revision `oneuse`: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/associated-types/cache/project-fn-ret-invariant.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--cfg" "oneuse" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.nll" "-Zborrowck=mir" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.nll/auxiliary"
stdout: none
--- stderr -------------------------------
error: lifetime may not live long enough
   |
   |
LL | fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
   |        --  -- lifetime `'b` defined here
   |        |
   |        lifetime `'a` defined here
LL |     let f = foo; // <-- No consistent type can be inferred for `f` here.
LL |     let a = bar(f, x);
   |             ^^^^^^^^^ argument requires that `'a` must outlive `'b`
   |
   = help: consider adding the following bound: `'a: 'b`
   = note: requirement occurs because of the type `Type<'_>`, which makes the generic argument `'_` invariant
   = note: the struct `Type<'a>` is invariant over the parameter `'a`
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
  --> /checkout/src/test/ui/associated-types/cache/project-fn-ret-invariant.rs:40:13
   |
   |
LL | fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
   |        --  -- lifetime `'b` defined here
   |        |
   |        lifetime `'a` defined here
...
LL |     let b = bar(f, y); //[oneuse]~ ERROR lifetime mismatch [E0623]
   |             ^^^^^^^^^ argument requires that `'b` must outlive `'a`
   |
   = help: consider adding the following bound: `'b: 'a`
   = note: requirement occurs because of the type `Type<'_>`, which makes the generic argument `'_` invariant
   = note: the struct `Type<'a>` is invariant over the parameter `'a`
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance

help: `'a` and `'b` must be the same: replace one with the other
error: aborting due to 2 previous errors
------------------------------------------



---- [ui (nll)] ui/hr-subtype/hr-subtype.rs#free_inv_x_vs_free_inv_y stdout ----

13    | |______________- in this macro invocation
14    |
14    |
15    = help: consider adding the following bound: `'x: 'y`
Some tests failed in compiletest suite=ui compare_mode=Nll mode=ui host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
-    = note: requirement occurs because of the type Inv<'_>, which makes the generic argument '_ invariant
-    = note: the struct Inv<'a> is invariant over the parameter 'a
+    = note: requirement occurs because of the type `Inv<'_>`, which makes the generic argument `'_` invariant
+    = note: the struct `Inv<'a>` is invariant over the parameter `'a`
18    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
19    = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)

33    | |______________- in this macro invocation
34    |
34    |
35    = help: consider adding the following bound: `'x: 'y`
-    = note: requirement occurs because of the type Inv<'_>, which makes the generic argument '_ invariant
-    = note: the struct Inv<'a> is invariant over the parameter 'a
+    = note: requirement occurs because of the type `Inv<'_>`, which makes the generic argument `'_` invariant
+    = note: the struct `Inv<'a>` is invariant over the parameter `'a`
38    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
39    = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)


The actual stderr differed from the expected stderr.
The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr
To only update this specific test, also pass `--test-args hr-subtype/hr-subtype.rs`


error in revision `free_inv_x_vs_free_inv_y`: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/hr-subtype/hr-subtype.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--cfg" "free_inv_x_vs_free_inv_y" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll" "-Zborrowck=mir" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll/auxiliary"
stdout: none
--- stderr -------------------------------
error: lifetime may not live long enough
   |
   |
LL |           fn subtype<'x, 'y: 'x, 'z: 'y>() {
   |                      --  -- lifetime `'y` defined here
   |                      |
   |                      lifetime `'x` defined here
LL |               gimme::<$t2>(None::<$t1>);
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y`
...
LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
LL | | fn(Inv<'y>)) }
   |
   |
   = help: consider adding the following bound: `'x: 'y`
   = note: requirement occurs because of the type `Inv<'_>`, which makes the generic argument `'_` invariant
   = note: the struct `Inv<'a>` is invariant over the parameter `'a`
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
   = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
error: lifetime may not live long enough
  --> /checkout/src/test/ui/hr-subtype/hr-subtype.rs:45:13
   |
   |
LL |           fn supertype<'x, 'y: 'x, 'z: 'y>() {
   |                        --  -- lifetime `'y` defined here
   |                        |
   |                        lifetime `'x` defined here
LL |               gimme::<$t1>(None::<$t2>);
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y`
...
LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
LL | | fn(Inv<'y>)) }
   |
   |
   = help: consider adding the following bound: `'x: 'y`
   = note: requirement occurs because of the type `Inv<'_>`, which makes the generic argument `'_` invariant
   = note: the struct `Inv<'a>` is invariant over the parameter `'a`
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
   = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
------------------------------------------



---- [ui (nll)] ui/match/match-ref-mut-invariance.rs stdout ----
diff of stderr:

9    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
10    |
11    = help: consider adding the following bound: `'a: 'b`
-    = note: requirement occurs because of a mutable reference to &i32
+    = note: requirement occurs because of a mutable reference to `&i32`
13    = note: mutable references are invariant over their type parameter
14    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance


The actual stderr differed from the expected stderr.
The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/match/match-ref-mut-invariance.nll/match-ref-mut-invariance.nll.stderr
To only update this specific test, also pass `--test-args match/match-ref-mut-invariance.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/match/match-ref-mut-invariance.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/match/match-ref-mut-invariance.nll" "-Zborrowck=mir" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/match/match-ref-mut-invariance.nll/auxiliary"
stdout: none
--- stderr -------------------------------
error: lifetime may not live long enough
   |
   |
LL | impl<'b> S<'b> {
   |      -- lifetime `'b` defined here
LL |     fn bar<'a>(&'a mut self) -> &'a mut &'a i32 {
   |            -- lifetime `'a` defined here
LL |         match self.0 { ref mut x => x } //~ ERROR mismatched types
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
   |
   = help: consider adding the following bound: `'a: 'b`
   = note: requirement occurs because of a mutable reference to `&i32`
   = note: mutable references are invariant over their type parameter
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: aborting due to previous error
------------------------------------------



---- [ui (nll)] ui/match/match-ref-mut-let-invariance.rs stdout ----
diff of stderr:

10    |         ^ associated function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
11    |
12    = help: consider adding the following bound: `'a: 'b`
-    = note: requirement occurs because of a mutable reference to &i32
+    = note: requirement occurs because of a mutable reference to `&i32`
14    = note: mutable references are invariant over their type parameter
15    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance


The actual stderr differed from the expected stderr.
The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/match/match-ref-mut-let-invariance.nll/match-ref-mut-let-invariance.nll.stderr
To only update this specific test, also pass `--test-args match/match-ref-mut-let-invariance.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/match/match-ref-mut-let-invariance.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/match/match-ref-mut-let-invariance.nll" "-Zborrowck=mir" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/match/match-ref-mut-let-invariance.nll/auxiliary"
stdout: none
--- stderr -------------------------------
error: lifetime may not live long enough
   |
   |
LL | impl<'b> S<'b> {
   |      -- lifetime `'b` defined here
LL |     fn bar<'a>(&'a mut self) -> &'a mut &'a i32 {
   |            -- lifetime `'a` defined here
LL |         let ref mut x = self.0;
LL |         x //~ ERROR mismatched types
   |         ^ associated function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
   |
   = help: consider adding the following bound: `'a: 'b`
   = note: requirement occurs because of a mutable reference to `&i32`
   = note: mutable references are invariant over their type parameter
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: aborting due to previous error
------------------------------------------



---- [ui (nll)] ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs stdout ----
diff of stderr:

23    |     ^^^^^^^^^^ argument requires that `'b` must outlive `'a`
24    |
25    = help: consider adding the following bound: `'b: 'a`
-    = note: requirement occurs because of a mutable reference to &isize
+    = note: requirement occurs because of a mutable reference to `&isize`
27    = note: mutable references are invariant over their type parameter
28    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance


The actual stderr differed from the expected stderr.
The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.nll/region-multiple-lifetime-bounds-on-fns-where-clause.nll.stderr
To only update this specific test, also pass `--test-args regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.nll" "-Zborrowck=mir" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.nll/auxiliary"
stdout: none
--- stderr -------------------------------
error: lifetime may not live long enough
   |
   |
LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
   |      --  -- lifetime `'b` defined here
   |      |
   |      lifetime `'a` defined here
LL |     // Illegal now because there is no `'b:'a` declaration.
LL |     *x = *y; //~ ERROR E0623
   |     ^^^^^^^ assignment requires that `'b` must outlive `'a`
   |
   = help: consider adding the following bound: `'b: 'a`
error: lifetime may not live long enough
  --> /checkout/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:5
   |
   |
LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
   |      -- -- lifetime `'b` defined here
   |      |
   |      lifetime `'a` defined here
...
LL |     a(x, y, z); //~ ERROR lifetime mismatch [E0623]
   |     ^^^^^^^^^^ argument requires that `'b` must outlive `'a`
   |
   = help: consider adding the following bound: `'b: 'a`
   = note: requirement occurs because of a mutable reference to `&isize`
   = note: mutable references are invariant over their type parameter
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error[E0308]: mismatched types
  --> /checkout/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12
   |
   |
LL |     let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; //~ ERROR E0308
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
   |
   = note: expected fn pointer `for<'r, 's, 't0, 't1, 't2, 't3> fn(&'r mut &'s isize, &'t0 mut &'t1 isize, &'t2 mut &'t3 isize)`
              found fn pointer `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize)`
error[E0308]: mismatched types
  --> /checkout/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12
   |
   |
LL |     let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; //~ ERROR E0308
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
   |
   = note: expected fn pointer `for<'r, 's, 't0, 't1, 't2, 't3> fn(&'r mut &'s isize, &'t0 mut &'t1 isize, &'t2 mut &'t3 isize)`
              found fn pointer `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize)`
error[E0308]: mismatched types
  --> /checkout/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12
   |
   |
LL |     let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; //~ ERROR E0308
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
   |
   = note: expected fn pointer `for<'r, 's, 't0, 't1, 't2, 't3> fn(&'r mut &'s isize, &'t0 mut &'t1 isize, &'t2 mut &'t3 isize)`
              found fn pointer `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize)`
error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0308`.
------------------------------------------
------------------------------------------


---- [ui (nll)] ui/regions/region-lifetime-bounds-on-fns-where-clause.rs stdout ----
diff of stderr:

23    |     ^^^^^^^ argument requires that `'b` must outlive `'a`
24    |
25    = help: consider adding the following bound: `'b: 'a`
-    = note: requirement occurs because of a mutable reference to &isize
+    = note: requirement occurs because of a mutable reference to `&isize`
27    = note: mutable references are invariant over their type parameter
28    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance


The actual stderr differed from the expected stderr.
The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.nll/region-lifetime-bounds-on-fns-where-clause.nll.stderr
To only update this specific test, also pass `--test-args regions/region-lifetime-bounds-on-fns-where-clause.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.nll" "-Zborrowck=mir" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.nll/auxiliary"
stdout: none
--- stderr -------------------------------
error: lifetime may not live long enough
   |
   |
LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) {
   |      --  -- lifetime `'b` defined here
   |      |
   |      lifetime `'a` defined here
LL |     // Illegal now because there is no `'b:'a` declaration.
LL |     *x = *y; //~ ERROR E0623
   |     ^^^^^^^ assignment requires that `'b` must outlive `'a`
   |
   = help: consider adding the following bound: `'b: 'a`
error: lifetime may not live long enough
  --> /checkout/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs:14:5
   |
   |
LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) {
   |      -- -- lifetime `'b` defined here
   |      |
   |      lifetime `'a` defined here
...
LL |     a(x, y); //~ ERROR lifetime mismatch [E0623]
   |     ^^^^^^^ argument requires that `'b` must outlive `'a`
   |
   = help: consider adding the following bound: `'b: 'a`
   = note: requirement occurs because of a mutable reference to `&isize`
   = note: mutable references are invariant over their type parameter
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error[E0308]: mismatched types
  --> /checkout/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs:20:12
   |
   |
LL |     let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR mismatched types
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
   |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants